"""
有疑问可以联系
邮箱1758082652@qq.com
QQ1758082652
"""
from machine import reset,Pin
from time import sleep
import linkWifi
import Gateway
import parsing
import socket

"""wifi修改成自己要连的wifi"""
ssid = "wifi名称"
passwd = "wifi密码"

wifi = linkWifi.Wlan(ssid,passwd)
wifi.connect_wifi()

while not wifi.isConnected():
  pass

"""设备标识和设备传输密钥自行修改"""

gateway = Gateway.Gateway("设备标识", "设备传输密钥", parsing.parsing)
state = gateway.connectToServer()

def gpio_value(obj,value):
    if value!=None:
        obj.obj.value(value)
    else:
        return obj.obj.value()

gpio14 = Pin(14,Pin.OUT,Pin.PULL_UP)
gpio14.value(1)

"""执行器标识自行修改"""
device = Gateway.Device("jsj_button", gpio14,gpio_value,False)
gateway.addDevice(device)

while wifi.isConnected() and state:
    gateway.sendToServer()
    gateway.sendToServerKeep()
    gateway.recvToServer()


reset()
print("系统重新启动")


